<template>
  <div class="goods-list-item" @click="itemClick">
    <img :src="imgSrc" @load="imgload"/>
    <p>{{goodslistitem.title}}</p>
    <p>
      <span>{{goodslistitem.price}}</span>
      <span>{{goodslistitem.cfav}}</span>
    </p>
  </div>
</template>

<script>
export default {
  props: {
    goodslistitem: {
      type: Object,
      default() {
        return {};
      }
    }
  },
  methods: {
    imgload() {
      if(this.$route.path.indexOf('/home') !== -1){
        this.$bus.$emit('imgfinishload')
      }else if(this.$route.path.indexOf('/detail') !== -1){
        this.$bus.$emit("detailImgLoad")
      }      
    },
    itemClick() {
      this.$router.push('/detail/' + this.goodslistitem.iid)
    }
  },
  computed: {
    imgSrc() {
      return this.goodslistitem.image || this.goodslistitem.show.img
    }
  }
};
</script>

<style scoped>
.goods-list-item {
  width: 100%;
}

.goods-list-item img {
  width: 95%;
  border-radius: 8px;
}

.goods-list-item p:nth-child(2) {
  display: inline-block;
  width: 90%;
  font-size: 14px;
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
}

.goods-list-item p span:nth-child(1) {
  color: red;
  font-size: 16px;
}

.goods-list-item p span:nth-child(2)::before {
  content: "";
  display: inline-block;
  width: 15px;
  height: 15px;
  background: url("~@/assets/img/detail/detail_bottom.png") 0 0 / 15px;
  margin: 0 5px;
}

.goods-list-item p span:nth-child(2) {
  font-size: 14px;
}
</style>
